layout.tsx 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. import { Inter, Permanent_Marker } from "next/font/google";
  2. import { GeistSans } from "geist/font/sans";
  3. import { GeistMono } from "geist/font/mono";
  4. import { cn } from "@/shared/lib/utils";
  5. import { generateStructuredData, StructuredDataScript } from "@/shared/lib/structured-data";
  6. import { getServerUrl } from "@/shared/lib/server-url";
  7. import { SiteConfig } from "@/shared/config/site-config";
  8. import { WorkoutSessionsSynchronizer } from "@/features/workout-session/ui/workout-sessions-synchronizer";
  9. import { ThemeSynchronizer } from "@/features/theme/ui/ThemeSynchronizer";
  10. import { Header } from "@/features/layout/Header";
  11. import { Footer } from "@/features/layout/Footer";
  12. import { TailwindIndicator } from "@/components/utils/TailwindIndicator";
  13. import { NextTopLoader } from "@/components/ui/next-top-loader";
  14. import { ServiceWorkerRegistration } from "@/components/pwa/ServiceWorkerRegistration";
  15. import { Providers } from "./providers";
  16. import type { ReactElement } from "react";
  17. import type { Metadata } from "next";
  18. import "@/shared/styles/globals.css";
  19. export const metadata: Metadata = {
  20. title: {
  21. default: SiteConfig.title,
  22. template: `%s | ${SiteConfig.title}`,
  23. },
  24. description: SiteConfig.description,
  25. keywords: SiteConfig.keywords,
  26. applicationName: SiteConfig.seo.applicationName,
  27. category: SiteConfig.seo.category,
  28. classification: SiteConfig.seo.classification,
  29. metadataBase: new URL(getServerUrl()),
  30. manifest: "/manifest.json",
  31. robots: {
  32. index: true,
  33. follow: true,
  34. googleBot: {
  35. index: true,
  36. follow: true,
  37. "max-snippet": -1,
  38. "max-image-preview": "large",
  39. "max-video-preview": -1,
  40. },
  41. },
  42. verification: {
  43. google: process.env.GOOGLE_SITE_VERIFICATION,
  44. },
  45. openGraph: {
  46. title: SiteConfig.title,
  47. description: SiteConfig.description,
  48. url: getServerUrl(),
  49. siteName: SiteConfig.title,
  50. images: [
  51. {
  52. url: `${getServerUrl()}/images/default-og-image_fr.jpg`,
  53. width: SiteConfig.seo.ogImage.width,
  54. height: SiteConfig.seo.ogImage.height,
  55. alt: `${SiteConfig.title} - Plateforme de fitness moderne`,
  56. },
  57. {
  58. url: `${getServerUrl()}/images/default-og-image_en.jpg`,
  59. width: SiteConfig.seo.ogImage.width,
  60. height: SiteConfig.seo.ogImage.height,
  61. alt: `${SiteConfig.title} - Modern fitness platform`,
  62. },
  63. ],
  64. locale: "fr_FR",
  65. type: "website",
  66. },
  67. twitter: {
  68. card: "summary_large_image",
  69. site: SiteConfig.seo.twitterHandle,
  70. creator: SiteConfig.seo.twitterHandle,
  71. title: SiteConfig.title,
  72. description: SiteConfig.description,
  73. images: [
  74. {
  75. url: `${getServerUrl()}/images/default-og-image_fr.jpg`,
  76. width: SiteConfig.seo.ogImage.width,
  77. height: SiteConfig.seo.ogImage.height,
  78. alt: `${SiteConfig.title} - Plateforme de fitness moderne`,
  79. },
  80. ],
  81. },
  82. alternates: {
  83. canonical: "https://www.workout.cool",
  84. languages: {
  85. "fr-FR": "https://www.workout.cool/fr",
  86. "en-US": "https://www.workout.cool/en",
  87. "x-default": "https://www.workout.cool",
  88. },
  89. },
  90. authors: [{ name: SiteConfig.company.name, url: getServerUrl() }],
  91. creator: SiteConfig.company.name,
  92. publisher: SiteConfig.company.name,
  93. formatDetection: {
  94. email: false,
  95. address: false,
  96. telephone: false,
  97. },
  98. appleWebApp: {
  99. capable: true,
  100. statusBarStyle: "default",
  101. title: SiteConfig.title,
  102. },
  103. icons: {
  104. icon: [
  105. { url: "/images/favicon-32x32.png", sizes: "32x32", type: "image/png" },
  106. { url: "/images/favicon-16x16.png", sizes: "16x16", type: "image/png" },
  107. { url: "/images/favicon.ico", type: "image/x-icon" },
  108. ],
  109. apple: [{ url: "/apple-touch-icon.png", sizes: "180x180", type: "image/png" }],
  110. shortcut: "/images/favicon.ico",
  111. },
  112. other: {
  113. "msapplication-TileColor": "#FF5722",
  114. "msapplication-TileImage": "/android-chrome-192x192.png",
  115. },
  116. };
  117. const inter = Inter({
  118. subsets: ["latin"],
  119. variable: "--font-inter",
  120. display: "swap",
  121. });
  122. const permanentMarker = Permanent_Marker({
  123. weight: "400",
  124. subsets: ["latin"],
  125. variable: "--font-permanent-marker",
  126. display: "swap",
  127. });
  128. export const preferredRegion = ["fra1", "sfo1", "iad1"];
  129. interface RootLayoutProps {
  130. params: Promise<{ locale: string }>;
  131. children: ReactElement;
  132. }
  133. export default async function RootLayout({ params, children }: RootLayoutProps) {
  134. const { locale } = await params;
  135. // Generate structured data
  136. const websiteStructuredData = generateStructuredData({
  137. type: "WebSite",
  138. locale,
  139. });
  140. const organizationStructuredData = generateStructuredData({
  141. type: "Organization",
  142. locale,
  143. });
  144. const webAppStructuredData = generateStructuredData({
  145. type: "WebApplication",
  146. locale,
  147. });
  148. return (
  149. <>
  150. <html className="h-full" dir="ltr" lang={locale} suppressHydrationWarning>
  151. <head>
  152. <meta charSet="UTF-8" />
  153. <meta content="width=device-width, initial-scale=1, maximum-scale=1 viewport-fit=cover" name="viewport" />
  154. {/* PWA Meta Tags */}
  155. <meta content="yes" name="apple-mobile-web-app-capable" />
  156. <meta content="default" name="apple-mobile-web-app-status-bar-style" />
  157. <meta content="Workout Cool" name="apple-mobile-web-app-title" />
  158. <meta content="yes" name="mobile-web-app-capable" />
  159. <meta content="#FF5722" name="msapplication-TileColor" />
  160. <meta content="/android-chrome-192x192.png" name="msapplication-TileImage" />
  161. {/* PWA Manifest */}
  162. <link href="/manifest.json" rel="manifest" />
  163. {/* eslint-disable-next-line @next/next/no-page-custom-font */}
  164. <link as="style" href="https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap" rel="preload" />
  165. {/* Alternate hreflang for i18n */}
  166. <link href="https://www.workout.cool/fr" hrefLang="fr" rel="alternate" />
  167. <link href="https://www.workout.cool/en" hrefLang="en" rel="alternate" />
  168. {/* Theme color for PWA */}
  169. <meta content="#FF5722" name="theme-color" />
  170. {/* Structured Data */}
  171. <StructuredDataScript data={websiteStructuredData} />
  172. <StructuredDataScript data={organizationStructuredData} />
  173. <StructuredDataScript data={webAppStructuredData} />
  174. </head>
  175. <body
  176. className={cn(
  177. "flex items-center justify-center min-h-screen w-full p-8 max-sm:p-0 max-sm:min-h-full bg-base-200 dark:bg-[#18181b] dark:text-gray-200 antialiased",
  178. "bg-hero-light dark:bg-hero-dark",
  179. GeistMono.variable,
  180. GeistSans.variable,
  181. inter.variable,
  182. permanentMarker.variable,
  183. )}
  184. suppressHydrationWarning
  185. >
  186. <Providers locale={locale}>
  187. <ServiceWorkerRegistration />
  188. <WorkoutSessionsSynchronizer />
  189. <ThemeSynchronizer />
  190. <NextTopLoader color="#FF5722" delay={100} showSpinner={false} />
  191. {/* Main Card Container */}
  192. <div className="card w-full max-w-3xl min-h-[500px] max-h-[90vh] h-[80vh] bg-white dark:bg-[#232324] shadow-xl border border-base-200 dark:border-slate-700 flex flex-col justify-between overflow-hidden max-sm:rounded-none max-sm:h-full rounded-lg">
  193. <Header />
  194. <div className="flex-1 overflow-auto flex flex-col">{children}</div>
  195. <Footer />
  196. </div>
  197. <TailwindIndicator />
  198. </Providers>
  199. </body>
  200. </html>
  201. </>
  202. );
  203. }